layui.use(['table', 'admin', 'ax'], function () {
    var $ = layui.$;
    var table = layui.table;
    var $ax = layui.ax;
    var admin = layui.admin;

    /**
     * 货运订单明细表管理
     */
    var OrderTransportDetailed = {
        tableId: "orderTransportDetailedTable"
    };

    /**
     * 初始化表格的列
     */
    OrderTransportDetailed.initColumn = function () {
        return [[
            {field: 'goodsName', sort: true, title: 'Product Name', style:'background-color: #dbf1e1;font-weight: 600;',width:200},
            {field: 'goodsNumber', sort: true, title: 'Product Code', style:'background-color: #dbf1e1;font-weight: 600;'},
            {field: 'goodsNo', sort: true, title: 'SKU No', style:'background-color: #dbf1e1;font-weight: 600;', totalRowText: 'Total:'},
            {field: 'num', sort: true, title: 'Quantity', totalRow: true, style:'background-color: #dbf1e1;font-weight: 600;'},
            {field: 'batchnumber', sort: true, title: 'Batch No'},
            {field: 'unitprice', sort: true, title: 'Unit Price'},
            {field: 'transportMoney', sort: true, title: 'Amount', totalRow: true},
            {field: 'transportPutvolume', sort: true, title: 'Volume', totalRow: true},
            {field: 'transportWeight', sort: true, title: 'Weight', totalRow: true},
            {field: 'largeclass', title: 'Category'},
            {field: 'goodsUnit', title: 'Unit'},
            {field: 'dpacking', title: 'Packaging'},
            {field: 'goodsSpecs', title: 'Specifications'},
        ]];
    };

    /**
     * 点击查询按钮
     */
    OrderTransportDetailed.search = function () {
        var queryData = {};
        queryData['condition'] = $("#condition").val();
        table.reload(OrderTransportDetailed.tableId, {
            where: queryData, page: {curr: 1},
             done:function () {
            }
        });
    };

    // 渲染表格
    var tableResult = table.render({
        elem: '#' + OrderTransportDetailed.tableId,
        url: Feng.ctxPath + '/orderTransportDetailed/list?transportNumber='+$("#transportNumber").val(),
        page: true,
        limit: 40,
        height: "full-60",
        totalRow: true,
        toolbar: '#toolbarfrom',
        cellMinWidth: 100,
        cols: OrderTransportDetailed.initColumn()
    });

    // 搜索按钮点击事件
    $('#btnSearch').click(function () {
        OrderTransportDetailed.search();
    });

});
